/**
 * Copyright (C) 2009 Ignasi Fosch Alonso
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
 * details.
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * You can reach me by mail at natx@y10k.ws
 * You can reach him by paper mail at:
 * C. LLEIDA, 41-43, 3r 1a
 * El Prat de Llobregat 08820
 * Barcelona, SPAIN
 */
package ws.y10k.goloim.model;

import static org.junit.Assert.*;

import org.junit.BeforeClass;
import org.junit.Test;

/**
 * @author natx
 *
 */
public class TestBoxes {
	
	private static Boxes boxes;

	/**
	 *
	 */
	@BeforeClass
	public static void setUpBeforeClass() {
		boxes = new Boxes();
	}
	
	/**
	 * Test method for {@link ws.y10k.goloim.model.Boxes#add(ws.y10k.goloim.model.Box)}.
	 */
	@Test(expected=BoxAlreadyExistsException.class)
	public final void testBasicOps() throws BoxAlreadyExistsException {
		assertFalse(boxes.boxExists(10, 20, 30, 0));
		try {
			boxes.add(new Box(10, 20, 30, 0));
		} catch (BoxAlreadyExistsException e) {
			fail("Failed adding a new box. Model response: This box already exists.");
		}
		assertTrue(boxes.boxExists(10.0, 20.0, 30.0, 0.0));
		try {
			@SuppressWarnings("unused")
			Box firstBox = boxes.getBox(10, 20, 30, 0);
		} catch (BoxDoesNotExistException e) {
			fail("Failed getting an existing box. Model response: This box doesn't exist.");
		}
		assertFalse(boxes.boxExists(10, 20, 30, 300));
		assertFalse(boxes.boxExists(200, 200, 200, 200));
		try {
			boxes.add(new Box(200,200,200,200));
		} catch (BoxAlreadyExistsException e) {
			fail("Failed adding a new box. Model response: This box already exists.");
		}
		assertTrue(boxes.boxExists(200, 200, 200, 200));
		boxes.add(new Box(10, 20, 30, 0));
	 
	}

}
